Skip to content

fix(telemetry): honor --config flag in enable/disable save path#375

Merged
Dumbris merged 1 commit into
mainfrom
fix/telemetry-config-flag-save-path
Apr 11, 2026
Merged

fix(telemetry): honor --config flag in enable/disable save path#375
Dumbris merged 1 commit into
mainfrom
fix/telemetry-config-flag-save-path

Conversation

@Dumbris

@Dumbris Dumbris commented Apr 11, 2026

Copy link
Copy Markdown
Member

Summary

  • mcpproxy telemetry enable / telemetry disable ignored the --config flag and always wrote to ~/.mcpproxy/mcp_config.json.
  • Root cause: loadTelemetryConfig() correctly honors the package-level configFile flag, but the save path was hardcoded to config.GetConfigPath(cfg.DataDir).
  • Introduces a small telemetryConfigSavePath(cfg) helper that prefers configFile when set, else falls back to the default. Applied to runTelemetryEnable, runTelemetryDisable, and runTelemetryShowPayload (the last one also passes the path to telemetry.New, which persists during legacy-install anonymous-ID initialization).

This is a pre-existing bug from PR #345 (Spec 036), not Spec 042.

Reproduction (before the fix)

TMPCFG=$(mktemp -d)/mcp_config.json
echo '{"listen":"127.0.0.1:0"}' > "$TMPCFG"
./mcpproxy --config "$TMPCFG" telemetry disable
# Before: writes to ~/.mcpproxy/mcp_config.json
# After:  writes to $TMPCFG

Test plan

  • go test ./cmd/mcpproxy/... -race -run Telemetry — passes
  • go test ./cmd/mcpproxy/... -race — passes
  • go build ./cmd/mcpproxy — succeeds
  • ./scripts/run-linter.sh — 0 issues
  • New regression tests with HOME sandboxed to t.TempDir():
    • TestRunTelemetryDisable_HonorsConfigFlag — disable writes to custom path, default path untouched
    • TestRunTelemetryEnable_HonorsConfigFlag — enable writes to custom path
    • TestTelemetryConfigSavePath_PrefersConfigFileFlag — helper unit test

Scope notes

  • Strictly touches cmd/mcpproxy/telemetry_cmd.go plus a new in-package test file.
  • runTelemetryShowPayload was trivially updated to use the helper; a sister PR retargeting show-payload to daemon-mode can extend or refactor this call site without conflict.
  • runTelemetryStatus is read-only and untouched.

Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

🤖 Generated with Claude Code

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Apr 11, 2026

Copy link
Copy Markdown

Deploying mcpproxy-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6eba334
Status: ✅  Deploy successful!
Preview URL: https://f72dc827.mcpproxy-docs.pages.dev
Branch Preview URL: https://fix-telemetry-config-flag-sa.mcpproxy-docs.pages.dev

View logs

@github-actions

github-actions Bot commented Apr 11, 2026

Copy link
Copy Markdown

📦 Build Artifacts

Workflow Run: View Run
Branch: fix/telemetry-config-flag-save-path

Available Artifacts

  • archive-darwin-amd64 (26 MB)
  • archive-darwin-arm64 (23 MB)
  • archive-linux-amd64 (15 MB)
  • archive-linux-arm64 (13 MB)
  • archive-windows-amd64 (25 MB)
  • archive-windows-arm64 (23 MB)
  • frontend-dist-pr (0 MB)
  • installer-dmg-darwin-amd64 (19 MB)
  • installer-dmg-darwin-arm64 (17 MB)

How to Download

Option 1: GitHub Web UI (easiest)

  1. Go to the workflow run page linked above
  2. Scroll to the bottom "Artifacts" section
  3. Click on the artifact you want to download

Option 2: GitHub CLI

gh run download 24275590729 --repo smart-mcp-proxy/mcpproxy-go

Note: Artifacts expire in 14 days.

The telemetry enable/disable commands correctly loaded config via
loadTelemetryConfig() (which honors the --config flag) but then
hardcoded the save path to config.GetConfigPath(cfg.DataDir), so
`mcpproxy --config /custom.json telemetry disable` always wrote to
~/.mcpproxy/mcp_config.json instead of the custom path. This is a
pre-existing bug introduced in PR #345 (Spec 036), not Spec 042.

Add a small telemetryConfigSavePath helper that mirrors the load
logic: prefer the package-level configFile flag when set, else fall
back to GetConfigPath(DataDir). Apply it to runTelemetryEnable,
runTelemetryDisable, and runTelemetryShowPayload (the latter passes
the path to telemetry.New which persists the anonymous ID). Adds
regression tests covering both enable and disable, plus a direct
helper unit test, with HOME sandboxed to t.TempDir() so accidental
writes to the real home config are detected.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Dumbris Dumbris force-pushed the fix/telemetry-config-flag-save-path branch from 1157868 to 6eba334 Compare April 11, 2026 05:22
@Dumbris Dumbris merged commit bbd2a47 into main Apr 11, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants